package com.ruoyi.web.controller.doulai;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.Request2MapUtil;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.GiveLog;
import com.ruoyi.system.service.IGiveLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.ExcelUtil;

import javax.servlet.http.HttpServletRequest;

/**
 * 赠送记录 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-01-06
 */
@Controller
@RequestMapping("/doulai/giveLog")
public class GiveLogController extends BaseController
{
    private String prefix = "doulai/giveLog";
	
	@Autowired
	private IGiveLogService giveLogService;

	@GetMapping()
	public String giveLog()
	{
	    return "/pages/present/present";
	}

	/**
	 * 查询赠送记录列表
	 */
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(GiveLog giveLog)
	{
		startPage();
        List<GiveLog> list = giveLogService.selectGiveLogList(giveLog);
		return getDataTable(list);
	}

	/**
	 * 剩余房卡和金币list
	 */
	@PostMapping("/userAcountlist")
	@ResponseBody
	public TableDataInfo userAcountlist(GiveLog giveLog)
	{
		startPage();
		List<GiveLog> list = giveLogService.selectUserAcountlist(giveLog);
		return getDataTable(list);
	}

	/**
	 * 系统赠送
	 */
	@Log(title = "赠送记录", businessType = BusinessType.UPDATE)
	@PostMapping("/give")
	@ResponseBody
	@Transactional(rollbackFor = Exception.class)
	public AjaxResult give(HttpServletRequest request, int gameUserId, int type, int giveCount)
	{
		Map<String, Object> stringObjectMap = new HashMap<>();
		stringObjectMap.put("gameUserId",gameUserId);
		stringObjectMap.put("type",type);
		stringObjectMap.put("giveCount",giveCount);
		stringObjectMap.put("createBy", ShiroUtils.getLoginName());
		return toAjax(giveLogService.give(stringObjectMap));
	}

}
